package io.tec.cloud.algorithm.c03_v20220607;

/**
 * 14	03_2	03	2	03链表结构、栈、队列、递归行为、哈希表和有序表	把链表中的给定值都删除
 */
public class Code03_2_DeleteGivenValue {

    public static Node removeValue(Node head, int num) {
        while (head != null) {
            if (head.v == num) {
                head = head.next;
            }
            break;
        }
        Node pre = head;
        Node cur = head;
        while (cur != null) {
            if (cur.v == num) {
                pre.next = cur.next;
            } else {
                pre = cur;
            }
            cur = cur.next;
        }
        return head;
    }


    static class Node {
        int v;
        Node next;
    }
}
